Music Object Extension - Clip

  Contents

About This Extension

The Clip extension provides a set of services for conveniently creating a music preview system on a Web page.

What's New in the Latest Version

There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.

Getting This Extension

To get the "music-object-x-clip.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-clip.js" into an appropriate folder of the local copy of your Web site.

In case you have problems saving the file using the above link, the "music-object-x-clip.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.

Dependencies

In order to use this extension, the following JavaScript file(s) must first be sourced in...

For more information on using extensions, consult the section About Music Object Extensions.

Reference

 Name   Short Description 
Music.Clip Object Constructor
Music.Clip An object constructor that lets you create a new Music.Clip object instance.
Music.Clip Instance Methods
insertUI Lets you insert the user interface for a Music.Clip object instance at the position within the document where this method is called.
play Lets you play the music file that is loaded into a Music.Clip object instance.
stop Lets you stop the music file that is playing for a Music.Clip object instance.
Music.Clip Instance Properties
musicObject A reference to the Music Object instance that is used by a Music.Clip object instance.
Music.Clip Static Properties
Music.Clip.fadeOutTime An integer variable, specifying the default value that should be used for the FadeOutTimeINT parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.hoverDelay An integer variable, specifying the default value that should be used for the HoverDelayINT parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.hoverResetDelay An integer variable, specifying the default value that should be used for the HoverResetDelayINT parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.imagePath A string variable, specifying the URL path that is used to prefix all image URLs used by all Music.Clip object instances.
Music.Clip.imageHeight An integer variable, specifying the default value that should be used for the ImageHeightINT parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.imageUrl A string variable, specifying the default value that should be used for the ImageUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.imageWhileLoadingUrl A string variable, specifying the default value that should be used for the ImageWhileLoadingUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.imageWhilePlayingUrl A string variable, specifying the default value that should be used for the ImageWhilePlayingUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.imageWidth An integer variable, specifying the default value that should be used for the ImageWidthINT parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.instances An array of references to all the Music.Clip object instances that have been created in the document.
Music.Clip.musicUrl A string variable, specifying the default value that should be used for the MusicUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.restartIfPlaying A boolean variable, specifying the default value that should be used for the RestartIfPlayingBOOL parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.triggerType A string variable, specifying the default value that should be used for the TriggerTypeSTR parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.stopOnMouseOut A boolean variable, specifying the default value that should be used for the StopOnMouseOutBOOL parameter, if this parameter is not specified when creating Music.Clip object instances.
Music.Clip.stubPath A string variable, specifying the URL of the stub RMF file that is needed to instantiate the player instances used by all the Music.Clip object instances.
Static Methods
Music.newClips Provides a convenient way of creating multiple Music.Clip object instances in one single step.

Music.Clip Object Constructor

 Music.Clip

 
 CATEGORY   Object Constructor 
 MODULE   Music Object Extension - Clip 
 Min. Player Version   1.0.0 
 File Types Supported   RMF, MIDI, WAV, AIFF, AU 
 

The Music.Clip object constructor (a static method of the Music object) lets you create a new Music.Clip object instance.

SYNTAX    Music.Clip (
    ObjectNameSTR ,
    MusicUrlSTR ,
    ImageUrlSTR ,
    ImageWhileLoadingUrlSTR ,
    ImageWhilePlayingUrlSTR ,
    ImageWidthINT ,
    ImageHeightINT ,
    TriggerTypeSTR ,
    FadeOutTimeINT ,
    StopOnMouseOutBOOL ,
    RestartIfPlayingBOOL ,
    HoverDelayINT ,
    HoverResetDelayINT
)

RETURN VALUE    ClipOBJ

PARAMETERS
SPECIAL VALUES
VARIATIONS
Music.Clip Instance Methods

 insertUI

 
 CATEGORY   Instance Method (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Min. Player Version   1.0.0 
 

The insertUI instance method of the Music.Clip object lets you insert the user interface for a Music.Clip object instance at the position within the document where this method is called.

SYNTAX    insertUI ( LinkHrefSTR , LinkTargetSTR , LinkAltSTR )

SPECIAL VALUES
VARIATIONS
 play

 
 CATEGORY   Instance Method (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Min. Player Version   1.0.0 
 

The play instance method of the Music.Clip object lets you play the music file that is loaded into a Music.Clip object instance.

SYNTAX    play ( LoopingBOOL )

This method can be useful if you are not using the insertUI instance method in order to create the user interface for a Music.Clip object instance, but are instead creating your own custom interface.

VARIATIONS
NOTES
 stop

 
 CATEGORY   Instance Method (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Min. Player Version   1.0.0 
 

The stop instance method of the Music.Clip object lets you stop the music file that is playing for a Music.Clip object instance.

SYNTAX    stop ( )

This method can be useful if you are not using the insertUI instance method in order to create the user interface for a Music.Clip object instance, but are instead creating your own custom interface.

NOTES
Music.Clip Instance Properties

 musicObject

 
 CATEGORY   Instance Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   object 
 Access   read only 
 

The musicObject instance property of the Music.Clip object is a reference to the Music Object instance that is used by a Music.Clip object instance.

This property can be useful if there are other ways you would like to control the playback of a clip while it is playing, or if you'd like to indicate playback state for clips using your own custom code. As an example, you could create custom code to hook into the onPlay and onStop callbacks for the Music Object instances of all Music.Clip object instances, so as to update the window's status bar to indicate when clips are playing.

The following sample code listing shows how this could be achieved...

for (var clipNo = 0; clipNo < Music.Clip.instances.length; clipNo++) {
   var clipMO = Music.Clip.instances [clipNo].musicObject;
   clipMO.addCallbackHandler ('onPlay','window.status = "audio preview clip playing..."');
   clipMO.addCallbackHandler ('onStop','window.status = window.defaultStatus');
}

If this code is placed in the document after all Music.Clip object instances have been created, then the window's status bar will be updated each time any one of the clips starts or stops playing.

Music.Clip Static Properties

 Music.Clip.fadeOutTime

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   integer 
 Default Value   500 
 Access   read / write 
 

The Music.Clip.fadeOutTime static property is an integer variable, specifying the default value that should be used for the FadeOutTimeINT parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.hoverDelay

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   integer 
 Default Value   350 
 Access   read / write 
 

The Music.Clip.hoverDelay static property is an integer variable, specifying the default value that should be used for the HoverDelayINT parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.hoverResetDelay

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   integer 
 Default Value   1000 
 Access   read / write 
 

The Music.Clip.hoverResetDelay static property is an integer variable, specifying the default value that should be used for the HoverResetDelayINT parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.imagePath

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   an empty string 
 Access   read / write 
 

The Music.Clip.imagePath static property is a string variable, specifying the URL path that is used to prefix all image URLs used by all Music.Clip object instances.

 Music.Clip.imageHeight

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   integer 
 Default Value   13 
 Access   read / write 
 

The Music.Clip.imageHeight static property is an integer variable, specifying the default value that should be used for the ImageHeightINT parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.imageUrl

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   "preview-ready.gif" 
 Access   read / write 
 

The Music.Clip.imageUrl static property is a string variable, specifying the default value that should be used for the ImageUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.imageWhileLoadingUrl

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   not-ready.gif 
 Access   read / write 
 

The Music.Clip.imageWhileLoadingUrl static property is a string variable, specifying the default value that should be used for the ImageWhileLoadingUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.imageWhilePlayingUrl

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   preview-playing.gif 
 Access   read / write 
 

The Music.Clip.imageWhilePlayingUrl static property is a string variable, specifying the default value that should be used for the ImageWhilePlayingUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.imageWidth

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   integer 
 Default Value   18 
 Access   read / write 
 

The Music.Clip.imageWidth static property is an integer variable, specifying the default value that should be used for the ImageWidthINT parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.instances

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   array 
 Access   read only 
 

The Music.Clip.instances static property is an array of references to all the Music.Clip object instances that have been created in the document.

This property can be useful if there is an operation that you would like to perform on all clips in the document. As an example, if you wanted to insert the user interfaces for all clips in an automated manner, you could simply iterate through all the elements of the Music.Clip.instances array, calling the insertUI method for each instance.

The following sample code listing shows how this could be achieved...

for (var clipNo = 0; clipNo < Music.Clip.instances.length; clipNo++) {
   Music.Clip.instances [clipNo].insertUI ();
   document.writeln ('<BR>');
}

Not only does such an approach save some code size, but nothing would need to be done to change this code in the future if more Music.Clip object instances were created or specific instances were removed.

In another example, if you were creating a preview page using the Clip extension and you also wanted to have background music playing on that page, then you could use the Ducking extension to wire the Music Object instances for all the clips to the Music Object instance that will be playing the background music. The code to do this might look as follows...

for (var clipNo = 0; clipNo < Music.Clip.instances.length; clipNo++) {
   backgroundMO.addDuckingMasters (Music.Clip.instances [clipNo].musicObject);
}

In the above sample code snippet, it is assumed that the Clip extension and the Ducking extension have been sourced in, that all the Music.Clip object instances have been created, that the background music's Music Object instance has been created, etc.

 Music.Clip.musicUrl

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   "[*].rmf" 
 Access   read / write 
 

The Music.Clip.musicUrl static property is a string variable, specifying the default value that should be used for the MusicUrlSTR parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.restartIfPlaying

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   boolean 
 Default Value   null 
 Access   read / write 
 

The Music.Clip.restartIfPlaying static property is a boolean variable, specifying the default value that should be used for the RestartIfPlayingBOOL parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.triggerType

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value   "click" 
 Access   read / write 
 

The Music.Clip.triggerType static property is a string variable, specifying the default value that should be used for the TriggerTypeSTR parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.stopOnMouseOut

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   boolean 
 Default Value   false 
 Access   read / write 
 

The Music.Clip.stopOnMouseOut static property is a boolean variable, specifying the default value that should be used for the StopOnMouseOutBOOL parameter, if this parameter is not specified when creating Music.Clip object instances.

 Music.Clip.stubPath

 
 CATEGORY   Static Property (of Music.Clip) 
 MODULE   Music Object Extension - Clip 
 Type   string 
 Default Value    
 Access   read / write 
 

The Music.Clip.stubPath static property is a string variable, specifying the URL of the stub RMF file that is needed to instantiate the player instances used by all the Music.Clip object instances.

Static Methods

 Music.newClips

 
 CATEGORY   Static Method 
 MODULE   Music Object Extension - Clip 
 Min. Player Version   1.0.0 
 

The Music.newClips static method provides a convenient way of creating multiple Music.Clip object instances in one single step.

SYNTAX    Music.newClips ( ObjectName1STR , ObjectName2STR , ... , ObjectNameNSTR )

Calling the Music.newClips method essentially amounts to calling the Music.Clip object constructor multiple times, each time passing the next ObjectNameSTR parameter specified in the Music.newClips method's parameter list.

So, for example, the statement...

Music.newClips ('saphiku','bhapthala','tituli','laghlaza');

...would be equivalent to the block of statements...

new Music.Clip ('saphiku');
new Music.Clip ('bhapthala');
new Music.Clip ('tituli');
new Music.Clip ('laghlaza');

NOTES